package day05;

import java.util.Scanner;

public class Addition {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int score = 0;
        for (int i = 1; i <= 10; i++) {//10次循环
            //出题 答题 判分
            int a = (int) (Math.random() * 100 + 1), b = (int) (Math.random() * 100 + 1);
            int result = a + b;//存正确答案
            System.out.println("(" + i + ")" + a + "+" + b + "=?");

            System.out.println("算吧");
            int answer = scanner.nextInt();

            if (answer == result) {
                System.out.println("恭喜你答对了");//答对得分
                score += 10;
            } else {
                System.out.println("很遗憾你答错了");
            }
        }
        System.out.println("总分为：" + score);


        for (int i = 1; i < 9; i++) {
            System.out.println(i);
            if (i == 4) {
                break;//break(跳出循环)一定要配合if使用
            }
        }
    }
}
